package com.hht.wblib.hht;

import android.content.ComponentName;
import android.content.Context;
import android.text.TextUtils;

import com.hht.wblib.utils.IntentHelps;
import com.hht.wblib.bean.ConfigurationBean;
import com.hht.wblib.listener.WhiteBoardImp;

import java.io.File;

/**
 * Author:chen'hu
 * Time:2025/1/2 10:29
 * Description:This is HhtWhiteBoard
 */
public class HhtWhiteBoard extends WhiteBoardImp {


    public HhtWhiteBoard(Context context, ConfigurationBean configurationBean) {
        super(context, configurationBean);
    }

    @Override
    public boolean sendPicturesToWhiteBoard(File file) {

        return IntentHelps.getInstance(mContext)
                .setIntentConfigurator(intent -> {
                    intent.setAction(whiteBoardBean.getAction());
                    if (null != file && !TextUtils.isEmpty(file.getPath())) {
                        intent.putExtra(whiteBoardBean.getPutKey(), file.getPath());
                    }
                })
                .startActivity();
    }

    @Override
    public boolean openWhiteBoard() {
        return IntentHelps.getInstance(mContext)
                .setIntentConfigurator(intent -> {
                    intent.setAction(whiteBoardBean.getAction());
                    ComponentName componentName =
                            new ComponentName(whiteBoardBean.getPkgName(), whiteBoardBean.getClassName());
                    intent.setComponent(componentName);
                })
                .startActivity();
    }

    @Override
    public boolean openAnnotation() {
        if (annotationBean.isActivity()) {
            return IntentHelps.getInstance(mContext)
                    .setIntentConfigurator(intent -> {
                        intent.putExtra("extraAnnotationMode", true);
                        intent.putExtra("extraEndMeeting", false);
                        intent.putExtra("extraHideApp", false);
                        ComponentName componentName =
                                new ComponentName(annotationBean.getPkgName(), annotationBean.getClassName());
                        intent.setComponent(componentName);
                    })
                    .startActivity();
        } else {
            return IntentHelps.getInstance(mContext)
                    .setIntentConfigurator(intent -> {
                        ComponentName componentName =
                                new ComponentName(annotationBean.getPkgName(), annotationBean.getClassName());
                        intent.setComponent(componentName);
                    })
                    .startService();
        }
    }
}
